#!/bin/sh
set -e
cd cache/stages
tar xf ../sources/glibc*.bz2
cd glibc-2.14

DL=$(readelf -l /bin/sh | sed -n 's@.*interpret.*/tools\(.*\)]$@\1@p')
sed -i "s|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=$DL -o|" \
	scripts/test-installation.pl
unset DL

sed -i -e 's/"db1"/& \&\& $name ne "nss_test1"/' scripts/test-installation.pl

sed -i 's|@BASH@|/bin/bash|' elf/ldd.bash.in

patch -Np1 -i ../../sources/glibc-2.14-gcc_fix-1.patch


sed -i '195,213 s/PRIVATE_FUTEX/FUTEX_CLOCK_REALTIME/' \
	nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timed{rd,wr}lock.S

mkdir -v ../glibc-build
cd ../glibc-build

../glibc-2.14/configure --prefix=/usr \
	--disable-profile --enable-add-ons \
	--enable-kernel=2.6.22.5 --libexecdir=/usr/lib/glibc

make
touch /etc/ld.so.conf
make install
